
/*
this checks that all arguments are integers and are equal to one another in reverse order
*/

 NUM_EQ:
  PUSH(FP);
  MOV(FP,SP);

  PUSH(R1); //save R1

  MOV(R1, FPARG(1)); //R1=n
  CMP(R1,IMM(2));
  JUMP_LT(ARG_N_ERROR);
  INCR(R1);
  PUSH(FPARG(R1)); //intialize PUSH last argument
  DECR(R1);  

 L_EQ_LOOP:
  PUSH(FPARG(R1)); 
  CALL(NUM_EQ_BIN);
  DROP(1);
  CMP(R0,3);
  JUMP_EQ(L_EQ_F);
  DECR(R1);
  CMP(R1, 1); //check if n is 1
  JUMP_NE(L_EQ_LOOP);



MOV(R0, IMM(5));  

L_EQ_DONE:

  DROP(1);
  POP(R1);
  POP(FP);
  RETURN;

L_EQ_F:

MOV(R0, IMM(3));  
JUMP(L_LT_DONE);

#include "num_eq_bin.asm"
